package com.tanhua.app.service;

import com.tanhua.api.service.UserLocationApi;
import com.tanhua.app.Interceptor.UserHolder;
import com.tanhua.app.exception.BusinessException;
import com.tanhua.model.vo.ErrorResult;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

@Service
public class BaiduService {

    @DubboReference
    private UserLocationApi userLocationApi;

    // 上报地理为止
    public void updateLocation(Double latitude, Double longitude, String addrStr) {
        //更新地理为止
        Boolean flag = userLocationApi.updateLocation(UserHolder.getUserId(), longitude, latitude, addrStr);

        if (!flag) {
            throw new BusinessException(ErrorResult.LocationUploadError());
        }
    }
}
